//package com.example.dwhne.leonweather;
//
//import android.view.Gravity;
//import android.widget.Toast;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.logging.Handler;
//
//import interfaces.heweather.com.interfacesmodule.bean.Lang;
//import interfaces.heweather.com.interfacesmodule.bean.Unit;
//import interfaces.heweather.com.interfacesmodule.bean.air.now.AirNow;
//import interfaces.heweather.com.interfacesmodule.bean.air.now.AirNowCity;
//import interfaces.heweather.com.interfacesmodule.bean.basic.Basic;
//import interfaces.heweather.com.interfacesmodule.bean.weather.forecast.Forecast;
//import interfaces.heweather.com.interfacesmodule.bean.weather.forecast.ForecastBase;
//import interfaces.heweather.com.interfacesmodule.bean.weather.now.Now;
//import interfaces.heweather.com.interfacesmodule.bean.weather.now.NowBase;
//import interfaces.heweather.com.interfacesmodule.view.HeWeather;
//
//public class WeatherGet {
//
//    private String cityCN;
//    private String cityParent;
//    public WeatherGet(String cityCN,String cityParent){
//        this.cityCN=cityCN;
//        this.cityParent=cityParent;
//    }
//
//    private void WeatherGet(){
//
//        HeWeather.getWeatherNow(this, cityCN, Lang.CHINESE_SIMPLIFIED, Unit.METRIC,
//                new HeWeather.OnResultWeatherNowBeanListener() {
//                    @Override
//                    public void onError(Throwable e) {
////                        Log.i("Test", "onError: "+e);
////                        Toast toast = Toast.makeText(this, "请求超时，请检查网络连接并下拉刷新", Toast.LENGTH_SHORT);
////                        toast.setGravity(Gravity.TOP, 0, 10);
////                        toast.show();
//
//                    }
//                    @Override
//                    public void onSuccess(List<Now> dataObject) {
//                        Now now=dataObject.get(0);
//                        Basic basic=now.getBasic();
//                        NowBase nowBase=now.getNow();
//                        Map<String,String> map=new HashMap<String, String>();
//                        map.put("Location",basic.getLocation());//城市名称
//                        map.put("Tmp",nowBase.getTmp());//温度
//                        map.put("Cond_code",nowBase.getCond_code());//城市天气状况代码
//                        map.put("Cond_txt",nowBase.getCond_txt());
//                        map.put("Wind_dir",nowBase.getWind_dir());
//                        map.put("Wind_sc",nowBase.getWind_sc());
//
//
//                    }
//                });
//        HeWeather.getWeatherForecast(WeatherShow.this, cityCN, Lang.CHINESE_SIMPLIFIED, Unit.METRIC, new HeWeather.OnResultWeatherForecastBeanListener() {
//            @Override
//            public void onError(Throwable throwable) {
//
//            }
//
//            @Override
//            public void onSuccess(List<Forecast> list) {
//                List<ForecastBase> forecast=list.get(0).getDaily_forecast();
//                List<Map<String,Object>> tList=new ArrayList<Map<String,Object>>();
//                String txt1[]={"今天","明天","后天"};
//                for(int i=0;i<3;i++){
////                    Log.i("Test", "onSuccess: "+new Gson().toJson(forecast.get(0)));//今天
//                    Map<String,Object> map=new HashMap<String, Object>();
//                    map.put("Tmp",forecast.get(i).getTmp_max()+" / "+forecast.get(i).getTmp_min()+"℃");//最高气温
//                    map.put("Cond_txt",txt1[i]+"·"+forecast.get(i).getCond_txt_d());//天气信息
//                    int pngID=getResources().getIdentifier("a"+forecast.get(i).getCond_code_d(), "drawable", getApplicationInfo().packageName);
//                    map.put("Icon",pngID);//天气状况图标XXXXX要改
//                    map.put("Air","良");//免费版无法获取空气质量预报
//                    tList.add(i,map);
//                }
//
//            }
//        });
//        HeWeather.getAirNow(this, cityParent, Lang.CHINESE_SIMPLIFIED, Unit.METRIC, new HeWeather.OnResultAirNowBeansListener() {
//            @Override
//            public void onError(Throwable throwable) {
//            }
//
//            @Override
//            public void onSuccess(List<AirNow> list) {
//                AirNow air=list.get(0);
//                AirNowCity airNowCity=air.getAir_now_city();
//                Map<String,String> map=new HashMap<String, String>();
//                if(airNowCity.getQlty().equals("优")|airNowCity.getQlty().equals("良")){
//                    map.put("Qlty","空气"+airNowCity.getQlty());//空气质量描述
//                }else{
//                    map.put("Qlty",airNowCity.getQlty());//空气质量描述
//                }
//                map.put("Aqi",airNowCity.getAqi());//空气质量指数
//            }
//        });
//
//    }
//}
